home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / ibmpmaci.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  3KB  |  78 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    ibmpc_applemac
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. #define DOS_EOF    0x1A        /* MS-DOS old end-of-file */
  25.  
  26. static unsigned char translation_table[256] = 
  27.   {
  28.       0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, /* 11 */ 
  29.      12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, /* 23 */ 
  30.      24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35, /* 35 */ 
  31.      36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47, /* 47 */ 
  32.      48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59, /* 59 */ 
  33.      60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71, /* 71 */ 
  34.      72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83, /* 83 */ 
  35.      84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95, /* 95 */ 
  36.      96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, /* 107 */
  37.     108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, /* 119 */
  38.     120, 121, 122, 123, 124, 125, 126, 127, 130, 159, 142, 137, /* 131 */
  39.     138, 136, 140, 141, 144, 145, 143, 149, 148, 147, 128, 129, /* 143 */
  40.     131, 190, 174, 153, 154, 152, 158, 157,   0, 133, 134, 162, /* 155 */
  41.     163, 180,   0, 196, 135, 146, 151, 156, 150, 132, 187, 188, /* 167 */
  42.     192, 169, 170, 171, 172, 193, 199, 200,   0,   0,   0,   0, /* 179 */
  43.       0,   0,   0,   0, 184,   0, 186,   0,   0,   0,   0, 191, /* 191 */
  44.       0,   0, 194, 195,   0,   0, 198,   0,   0, 201, 202, 203, /* 203 */
  45.     204, 205, 206, 207, 208, 209, 210, 211, 212, 213,   0, 215, /* 215 */
  46.     216, 217, 218, 219, 220, 221, 222, 223, 224, 167, 226, 185, /* 227 */
  47.     183, 229, 181, 231, 232, 233, 189, 182, 176, 237, 238, 239, /* 239 */
  48.     240, 177, 179, 178, 244, 245, 214, 197, 161, 249, 165, 251, /* 251 */
  49.     252, 253, 254, 255,
  50.   };
  51.  
  52. void
  53. STEP (FILE *input_file, FILE *output_file)
  54. {
  55.   int input_char;        /* current character */
  56.   int output_char;        /* translated character */
  57.  
  58.   input_char = getc (input_file);
  59.   while (input_char != EOF && input_char != DOS_EOF)
  60.     if (input_char == 0x0D)
  61.       {
  62.     input_char = getc (input_file);
  63.     if (input_char == 0x0A)
  64.       {
  65.         putc ('\n', output_file);
  66.         input_char = getc (input_file);
  67.       }
  68.     else
  69.       putc (0x0D, output_file);
  70.       }
  71.     else
  72.       {
  73.     if ((output_char = translation_table[input_char]) != '\0')
  74.       putc (output_char, output_file);
  75.     input_char = getc (input_file);
  76.       }
  77. }
  78.